package com.solocredit.finance.data.dev.take

import android.content.Context
import android.os.Build
import com.google.gson.Gson
import com.solocredit.finance.data.dev.utils.FlexiMolaApp
import com.solocredit.finance.data.dev.utils.FlexiMolaHdwUtil
import com.solocredit.finance.data.dev.utils.FlexiMolaNetUtil
import com.solocredit.finance.data.dev.utils.FlexiMolaSdUtil

/**
 * Device
 */
class TakeFlexiMolaDev(val context: Context, val product: String, val token: String, val path: String) {

    fun takeFlexiMolaDev(): String? {
        return try {
            val data = hashMapOf<String, Any>().apply {
                put("path", path)
                put("token", token)
                put("product", product)
                put("imei", "")
                put("version", "30")
                put("app", product)
                put("manufacturer", Build.MANUFACTURER ?: "")
                put("brand", Build.BRAND ?: "")
                put("deviceName", Build.DEVICE ?: "")
                put("phoneModel", Build.PRODUCT ?: "")
                put("sysVersion", Build.VERSION.RELEASE ?: "")
                put("mac", FlexiMolaNetUtil.mcads())
                put("laguage", FlexiMolaApp.lang())
                put("area", FlexiMolaApp.area())
                put("screenHeight", FlexiMolaApp.dHht(context))
                put("screenWidth", FlexiMolaApp.dwh(context))
                put("networkData", FlexiMolaApp.sioName(context))
                put("frontCameraPixels", FlexiMolaHdwUtil.gfsiz(context))
                put("rearCameraPixels", FlexiMolaHdwUtil.bgsiz(context))
                put("ram", FlexiMolaSdUtil.talRSzi(context))
                put("rom", FlexiMolaSdUtil.toaDis())
                put("ip", FlexiMolaNetUtil.iads(context))
                put("ip2", FlexiMolaNetUtil.iads(context))
                put("networkEnvironment", FlexiMolaApp.wiType(context))
                put("cpu", FlexiMolaApp.cpSerial())
            }
            Gson().toJson(data).trim()

        } catch (e: Exception) {
            null
        }
    }
}